package com.edu.exam.enums.grading;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 成绩类型枚举
 * 管理学生成绩的各种类型分类
 *
 * @author System
 * @version 1.0.0
 */
public enum GradeType implements BaseEnum {

    DAILY("DAILY", "平时成绩", 1),
    MIDTERM("MIDTERM", "期中成绩", 2),
    FINAL("FINAL", "期末成绩", 3),
    QUIZ("QUIZ", "测验成绩", 4),
    ASSIGNMENT("ASSIGNMENT", "作业成绩", 5),
    EXPERIMENT("EXPERIMENT", "实验成绩", 6),
    PRACTICE("PRACTICE", "实践成绩", 7),
    PROJECT("PROJECT", "项目成绩", 8),
    THESIS("THESIS", "论文成绩", 9),
    COMPREHENSIVE("COMPREHENSIVE", "综合成绩", 10),
    EXEMPTION("EXEMPTION", "免修成绩", 11),
    MAKEUP("MAKEUP", "补考成绩", 12),
    RETAKE("RETAKE", "重修成绩", 13),
    ADJUSTMENT("ADJUSTMENT", "调整成绩", 14),
    OTHER("OTHER", "其他成绩", 99);

    private final String code;
    private final String description;
    private final int order;

    GradeType(String code, String description, int order) {
        this.code = code;
        this.description = description;
        this.order = order;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public int getOrder() {
        return order;
    }

    /**
     * 根据编码获取枚举
     */
    public static GradeType fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (GradeType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }
}